Actor ZombieCommando : RGAMonster
{
  Health 200
  Height 56
  Radius 10
  Speed 14
  PainChance 96
  Monster
  +FloorClip
  +NoTarget
  +NoInfighting
  +LOOKALLAROUND
  +BOSS
  +FULLVOLACTIVE
  SeeSound "ZSpecOps/Sight"
  ActiveSound "ZSpecOps/Sight"
  PainSound "ZSpecOps/Pain"
  DeathSound "ZSpecOps/Death"
  Obituary "%o couldn't handle Zombie Commando"
  Decal BulletChip
  dropitem AssaultRifleSpawner 100
  dropitem AssaultRifleAmmo 255
  dropitem AssaultRifleAmmo 128
  DropItem "HandgunAmmo" 128
  States
  {
  Spawn:
  	ZSP2 A 0
  	POSS A 0 Thing_SetSpecial(0,226,613,0,random(30,40))
  	POSS A 0 A_GiveInventory("XPAmount", random(30, 40))
  	POSS P 0 ACS_ExecuteAlways(651,0,0,0,0)
    ZSP2 AAAAAAAAAABBBBBBBBBB 1 A_Look
    goto Spawn+4

  //Switching
  See:
    ZSP2 A 0 A_JumpIfInventory("ZSpecOpAggressive", 1, "AggressiveSwitch")
    ZSP2 A 0 A_JumpIfInventory("ZSpecOpSnipe", 1, "SnipeSwitch")
    ZSP2 A 0 A_JumpIfInventory("ZSpecOpWander", 1, "WanderSwitch")
    ZSP2 A 0 A_JumpIfInventory("ZSpecOpCreep", 1, "CreepSwitch")
    ZSP2 A 0 A_JumpIfInventory("ZSpecOpFlee", 1, "FleeSwitch")
    goto AggressiveSee
  SitRep:
    ZSP2 A 0 A_TakeInventory("ZSpecOpAggressive", 1)
    ZSP2 A 0 A_TakeInventory("ZSpecOpSnipe", 1)
    ZSP2 A 0 A_TakeInventory("ZSpecOpWander", 1)
    ZSP2 A 0 A_TakeInventory("ZSpecOpCreep", 1)
    ZSP2 A 0 A_TakeInventory("ZSpecOpFlee", 1)
    ZSP2 A 0 A_ChangeFlag("MissileMore", 0)
    ZSP2 A 0 A_ChangeFlag("MissileEvenMore", 0)
    //ZSP2 A 0 A_ChangeFlag("AvoidMelee", 0)
    ZSP2 A 0 A_ChangeFlag("Frightened", 0)
    ZSP2 A 0 A_GiveInventory("ZSpecOpsMSitRep", 1)
    goto See 
  //Aggressive Mode
  AggressiveSwitch:
    ZSP2 A 0 A_ChangeFlag("MissileMore", 1)
    ZSP2 A 0 A_ChangeFlag("MissileEvenMore", 1)
    Goto AggressiveSee
  AggressiveSee:
    ZSP2 A 3 A_Chase("", "AggressiveMissile")
    ZSP2 A 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 A 0 A_Jump(32, 2)
    ZSP2 A 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 A 3 A_Chase("", "AggressiveMissile")
    ZSP2 A 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 A 0 A_Jump(32, 2)
    ZSP2 A 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 B 3 A_Chase("", "AggressiveMissile")
    ZSP2 B 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 B 0 A_Jump(32, 2)
    ZSP2 B 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 B 3 A_Chase("", "AggressiveMissile")
    ZSP2 B 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 B 0 A_Jump(32, 2)
    ZSP2 B 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 C 3 A_Chase("", "AggressiveMissile")
    ZSP2 C 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 C 0 A_Jump(32, 2)
    ZSP2 C 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 C 3 A_Chase("", "AggressiveMissile")
    ZSP2 C 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 C 0 A_Jump(32, 2)
    ZSP2 C 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 D 3 A_Chase("", "AggressiveMissile")
    ZSP2 D 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 D 0 A_Jump(32, 2)
    ZSP2 D 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 D 3 A_Chase("", "AggressiveMissile")
    ZSP2 D 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 D 0 A_Jump(32, 2)
    ZSP2 D 0 A_JumpIfCloser(768, 1)
    Goto SitRep
    ZSP2 A 0
    Loop
  AggressiveMissile:
    ZSP2 EEE 4 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 A_Jump(32, "AggressiveSee")
    ZSP2 F 0 A_Jump(192, 2)
    ZSP2 F 0 A_SpidRefire
    ZSP2 F 0
    Goto AggressiveMissile+3

  //Snipe Mode
  SnipeSwitch:
    ZSP2 A 0 A_ChangeFlag("MissileMore", 1)
    ZSP2 A 0 A_ChangeFlag("MissileEvenMore", 1)
    Goto SnipeSee
  SnipeSee:
    ZSP2 E 0 A_Chase("", "SnipeMissile", 17)
    ZSP2 EEEE 2 A_FaceTarget
    ZSP2 E 0 A_JumpIfCloser(384, "SitRep")
    ZSP2 E 0 A_CheckSight("SnipeIdle")
    Loop
  SnipeIdle:
    ZSP2 E 0 A_ClearTarget
    ZSP2 E 1 A_LookEx(10, 0, 0, 0, 360, "SnipeSee")
    Goto SnipeIdle+1
  SnipeMissile:
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(128, 2)
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(4, 3, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 E 0 A_Jump(192, "SnipeSee")
    ZSP2 E 0 A_SpidRefire
    Loop

  //Wander Mode
  WanderSwitch:
    ZSP2 A 0 A_ClearTarget
    Goto WanderSee
  WanderSee:
    ZSP2 A 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 A 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 B 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 B 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 C 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 C 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 D 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    ZSP2 D 4 A_Wander
    ZSP2 A 0 A_LookEx(10, 0, 0, 0, 360, "SitRep")
    Loop

  //Creep Mode
  CreepSwitch:
    ZSP2 A 0 A_ChangeFlag("MissileMore", 1)
    //ZSP2 A 0 A_ChangeFlag("AvoidMelee", 1)
    Goto CreepSee
  CreepSee:
    ZSP2 A 0 A_CheckSight("CreepCheck")
    ZSP2 A 0 A_JumpIfHealthLower(50, "SitRep")
    ZSP2 AABBCCDD 5 A_Chase("", "CreepMissile", 2)
    Loop
  CreepCheck:
    ZSP2 A 0 A_Jump(32, "SitRep")
    Goto CreepSee+1
  CreepMissile:
    ZSP2 EEE 4 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 A_Jump(32, "CreepSee")
    ZSP2 F 0 A_SpidRefire
    Goto CreepMissile+3

  //Flee Mode
  FleeSwitch:
    ZSP2 A 0 A_ChangeFlag("Frightened", 1)
    Goto FleeSee
  FleeSee:
    ZSP2 AABBCCDD 3 A_Chase("", "FleeMissile")
    ZSP2 A 0 A_JumpIfCloser(768, 1)
    Goto See
    ZSP2 A 0
    Loop
  FleeMissile:
    ZSP2 EE 4 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    ZSP2 F 0 Bright A_PlayWeaponSound("m4a1/fire")
    ZSP2 F 2 Bright A_CustomBulletAttack(11, 8, 1, 3, "BulletPuff")
    ZSP2 E 2 A_FaceTarget
    Goto FleeSee
  //Misc hurting states
  Pain:
    ZSP2 G 4
    ZSP2 G 4 A_Pain
    ZSP2 G 0 A_Jump(96, "SitRep")
    Goto SitRep
  Death:
    ZSP2 H 5
    ZSP2 I 5 A_Scream
    ZSP2 J 5
    ZSP2 K 5 A_NoBlocking
    ZSP2 K 0 ACS_ExecuteAlways(648,0,0,0,0)
    ZSP2 L -1
  Raise:
    ZSP2 LKJIH 5
    Goto SitRep
  }
}

Actor ZSpecOpsMSitRep : CustomInventory
{
  Inventory.MaxAmount 0
  +Inventory.AutoActivate
  States
  {
  Spawn:
    TNT1 A 1
    Fail

  Use:
    TNT1 A 0 A_JumpIfHealthLower(50, "LowHealth")
    TNT1 A 0 A_CheckSight("OutOfSight")
    TNT1 A 0 A_JumpIfCloser(384, "Close")
  ChecksFailed:
    TNT1 A 0 A_Jump(256, "AggressiveMode", "AggressiveMode", "SnipeMode")

  LowHealth:
    TNT1 A 0 A_CheckSight("LowHealthOutOfSight")
    TNT1 A 0 A_JumpIfCloser(768, "LowHealthClose")
    TNT1 A 0 A_Jump(256, "SnipeMode")
  LowHealthOutOfSight:
    TNT1 A 0 A_JumpIfCloser(768, "LowHealthOutOfSightClose")
    TNT1 A 0 A_Jump(256, "FleeMode", "SnipeMode")
  LowHealthOutOfSightClose:
    TNT1 A 0 A_Jump(256, "FleeMode")
  LowHealthClose:
    TNT1 A 0 A_Jump(256, "FleeMode")

  OutOfSight:
    TNT1 A 0 A_JumpIfCloser(384, "OutOfSightClose")
    TNT1 A 0 A_Jump(256, "AggressiveMode", "SnipeMode", "WanderMode", "CreepMode")
  OutOfSightClose:
    TNT1 A 0 A_Jump(256, "AggressiveMode", "CreepMode")

  Close:
    TNT1 A 0 A_Jump(256, "AggressiveMode")

  AggressiveMode:
    TNT1 A 0 A_GiveInventory("ZSpecOpAggressive", 1)
    Stop
  SnipeMode:
    TNT1 A 0 A_GiveInventory("ZSpecOpSnipe", 1)
    Stop
  WanderMode:
    TNT1 A 0 A_GiveInventory("ZSpecOpWander", 1)
    Stop
  CreepMode:
    TNT1 A 0 A_GiveInventory("ZSpecOpCreep", 1)
    Stop
  FleeMode:
    TNT1 A 0 A_GiveInventory("ZSpecOpFlee", 1)
    Stop
  }
}

Actor ZSpecOpAggressive : Inventory { Inventory.MaxAmount 1 }
Actor ZSpecOpSnipe : Inventory { Inventory.MaxAmount 1 }
Actor ZSpecOpWander : Inventory { Inventory.MaxAmount 1 }
Actor ZSpecOpCreep : Inventory { Inventory.MaxAmount 1 }
Actor ZSpecOpFlee : Inventory { Inventory.MaxAmount 1 }
